package utils;

import com.alibaba.fastjson.JSON;
import com.github.houbb.sensitive.word.bs.SensitiveWordBs;

import java.io.File;


public class TestString {
    public static void main(String[] args) throws Exception {

//        String str = "五星红旗迎风飘扬，胜利歌声多么响亮~~";
//        sensitiveWords(str);

//        String[] str  = {"a","b","c"};
//        stringListToJSONString(str);

        String str = "12a";
        matches(str);
    }

    //String[] 转 json格式字符串
    public static void stringListToJSONString(String[] str) {
        System.out.println(str);
        String json_arr_String = JSON.toJSONString(str);
        System.out.println(json_arr_String);
    }

    //敏感词判断
    public static void sensitiveWords(String str) {
        boolean a =  SensitiveWordBs.newInstance().contains(str);
        if(a){
            System.out.println("有");
        }else {
            System.out.println("无");
        }
    }

    //正则判断
    public static void matches(String str) {
        if(str.matches("^\\d+$")){
            System.out.println("yes");
        }else {
            System.out.println("no");
        }
    }
}